package com.itheima.appserver.controller;

import com.itheima.appserver.service.BaiDuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/baidu")
public class BaiDuController {
    @Autowired
    private BaiDuService baiDuService;

    @PostMapping("/location")
    public ResponseEntity location(@RequestBody Map map) {
        Double latitude = Double.valueOf(map.get("latitude").toString());
        Double longitude = Double.valueOf(map.get("longitude").toString());
        String addrStr = (String) map.get("addrStr");
        baiDuService.updatelocation(latitude, longitude, addrStr);
        return ResponseEntity.ok(null);
    }
}
